import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { RedisModule } from './redis/redis.module';
import { BaseModelModule } from './model/base-model/base-model.module';
import { DeviceModelModule } from './model/device-model/device-model.module';
import { ChargeStrategyModelModule } from './model/charge-strategy-model/charge-strategy-model.module';
import { ChargeOrderModelModule } from './model/charge-order-model/charge-order-model.module';
import config from './config';
import white from './config/white'
import { DevicePortModelModule } from './model/device-port-model/device-port-model.module';
import { ChargeOrderModule } from './module/charge-order/charge-order.module';
import { DeviceModule } from './module/device/device.module';
import { ChargeModule } from './message/charge/charge.module';
import { MessageModule } from './message/message/message.module';
import { MongooseModule } from '@nestjs/mongoose';
import { AddChargeOrderModelModule } from './model/add-charge-order-model/add-charge-order-model.module';
import { DeviceModule as ApiDeviceModule } from './api/device/device.module';
import { IccardChargeModule } from './message/iccard-charge/iccard-charge.module';
import { IccardModelModule } from './model/iccard-model/iccard-model.module';
import { IccardModule } from './module/iccard/iccard.module';

@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal : true,
      load : [config, white]
    }),

    TypeOrmModule.forRootAsync({
      inject : [ConfigService],
      useFactory : (configService:ConfigService) => configService.get('database')
    }),

    MongooseModule.forRootAsync({
      inject : [ConfigService],
      useFactory : (configService:ConfigService) => configService.get('mongodb')
    }),

    RedisModule,
    DeviceModule,
    

    BaseModelModule,
    DeviceModelModule,
    DevicePortModelModule,
    ChargeStrategyModelModule,

    ChargeOrderModelModule,
    AddChargeOrderModelModule,

    ChargeOrderModule,

    ChargeModule,

    MessageModule,

    ApiDeviceModule,

    IccardChargeModule,

    IccardModelModule,

    IccardModule

  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
